#include <glib.h>

gint main(gint argc, gchar **argv)
{
    GByteArray *barr = NULL;
    guint i = 0;
    gchar *str[4] = {NULL};

    str[0] = g_strdup("Hello");
    str[1] = g_strdup(",");
    str[2] = g_strdup("World");
    str[3] = g_strdup("\0");

    barr = g_byte_array_new();

    g_byte_array_append(barr, (guint8 *)str[0], 5);
    g_byte_array_append(barr, (guint8 *)str[1], 1);
    g_byte_array_append(barr, (guint8 *)str[2], 5);
    g_byte_array_append(barr, (guint8 *)str[3], 1);

    g_print("barr:(len:%d)%s \n", barr->len, barr->data);

    for(i=0; i<barr->len; i++) {
        g_print("barr->data[%d](addr:%p):%c \n", i, &barr->data[i], barr->data[i]);
    }
    g_print("\nlen=%d(addr:%p)\n", barr->len, &barr->len);

    g_free(str[0]);
    g_free(str[1]);
    g_free(str[2]);
    g_free(str[3]);
    
    g_byte_array_free(barr, TRUE);

    return 0;
}